const express = require('express');
const fs = require('fs');

const app = express();

app.all('/writeFile', (req, res) => {
  // 跨域允许
  res.setHeader('Access-Control-Allow-Origin', '*');
  // 任何头信息
  res.setHeader('Access-Control-Allow-Headers', '*');
  fs.writeFile(`${req.query.filepath}/${req.query.filename}`, req.query.content, 'utf-8', (error) => {
    if (error) {
      return error;
    }
  })
});

app.listen(3000, () => console.log('Server start at 3000 port....'));
